package utils
{
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;

	public class LabelInputNumber extends LabelInput
	{
		
		public function LabelInputNumber(text:String)
		{
			if (isNaN(Number(text)))
			{
				text = "0";
			}
			super(text);
		}
		
		override public function get text():String
		{
			return _textField.text;
		}

		override public function set text(value:String):void
		{
			if (!isNaN(Number(value)))
			{
				super.text = value;
			}
		}
		
		override protected function enterPress(event:KeyboardEvent):void
		{
			if (event.keyCode != Keyboard.ENTER) return void;
			super.enterPress(event);
			
			if (isNaN(Number(text)))
			{
				text = _oldText;
			}
		}
	}
}